package my.mark.mybaibaoxiang.eventDemo.nhr;

import org.springframework.context.ApplicationEvent;

/**
 * @author wxming.
 * @date 2025/8/7.
 * @Description 异步发送消息的事件
 */
public class PmMessageEvent extends ApplicationEvent {

    private static final long serialVersionUID = -4872832415916202519L;

    private String eventName;
    private PmMessageEventHandler eventHandler;

    public PmMessageEvent(Object source, String eventName, PmMessageEventHandler eventHandler) {
        super(source);
        this.eventName = eventName;
        this.eventHandler = eventHandler;
    }

    public String getEventName() {
        return eventName;
    }

    public PmMessageEventHandler getEventHandler() {
        return eventHandler;
    }

    @FunctionalInterface
    public interface PmMessageEventHandler {
        void run();
    }

    public static PmMessageEvent of(Object source, String eventName, PmMessageEventHandler eventHandler) {
        return new PmMessageEvent(source, eventName, eventHandler);
    }

}
